#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/hash_policy.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ps putchar(' ')
#define pe putchar('\n')
#define int long long
#define eb emplace_back
#define pi pair<int, int>
// #define mk make_pair
#define fi first
#define se second
#define Ad tr[p].ad
// #define Ad t[p].ad
#define ls p << 1
#define rs p << 1 | 1
// #define ls tr[p].son[0]
// #define rs tr[p].son[1]
// #define ls t[p].son[0]
// #define rs t[p].son[1]
#define len (r - l + 1)
#define mid ((l + r) >> 1)
using namespace std;
// using namespace __gnu_pbds;
inline int read()
{
    int f = 0, ans = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
const int N = 2e5 + 5, M = N << 2, inf = 1e18, mod = 998244353;
int n, a[N], b[N], ans[N];
int t, s[N], L[N], mk[N];
struct ST
{
    int f[18][N];
    inline void init()
    {
        for (int i = 1; i <= n; ++i)
            f[0][i] = read();
        int lg = __lg(n);
        for (int j = 1; j <= lg; ++j)
            for (int i = 1; i + (1 << j) - 1 <= n; ++i)
                f[j][i] = min(f[j - 1][i], f[j - 1][i + (1 << j - 1)]);
    }
    inline int ask(int l, int r)
    {
        int lg = __lg(len);
        return min(f[lg][l], f[lg][r - (1 << lg) + 1]);
    }
} st1, st2;
inline bool brute_force()
{
    if (n > 1000)
        return 0;
    for (int k = 1; k <= n; ++k)
    {
        int ans = inf;
        for (int i = 1, j; (j = i + k - 1) <= n; ++i)
            ans = min(ans, abs(st1.ask(i, j) - st2.ask(i, j)));
        write(ans), pe;
    }
    return 1;
}
inline bool check_A()
{
    for (int i = 1; i <= n; ++i)
        if (b[i] != 1)
            return 0;
    fill(mk + 1, mk + n + 1, inf);
    a[0] = -inf, a[n + 1] = -inf;
    s[t = 1] = 0;
    for (int i = 1; i <= n; ++i)
    {
        while (t && a[s[t]] >= a[i])
            --t;
        L[i] = s[t] + 1, s[++t] = i;
    }
    s[t = 1] = n + 1;
    for (int i = n; i; --i)
    {
        while (t && a[s[t]] >= a[i])
            --t;
        int l = L[i], r = s[t] - 1;
        mk[len] = min(mk[len], a[i]);
        s[++t] = i;
    }
    ans[n + 1] = inf;
    for (int i = n; i; --i)
        ans[i] = min(ans[i + 1], mk[i]);
    for (int i = 1; i <= n; ++i)
        write(abs(ans[i] - 1)), pe;
    return 1;
}
inline bool check_B()
{
    for (int i = 1; i <= n; ++i)
        if (b[i] != 1000000000)
            return 0;
    fill(mk + 1, mk + n + 1, -inf);
    a[0] = -inf, a[n + 1] = -inf;
    s[t = 1] = 0;
    for (int i = 1; i <= n; ++i)
    {
        while (t && a[s[t]] >= a[i])
            --t;
        L[i] = s[t] + 1, s[++t] = i;
    }
    s[t = 1] = n + 1;
    for (int i = n; i; --i)
    {
        while (t && a[s[t]] >= a[i])
            --t;
        int l = L[i], r = s[t] - 1;
        mk[len] = max(mk[len], a[i]);
        s[++t] = i;
    }
    ans[n + 1] = -inf;
    for (int i = n; i; --i)
        ans[i] = max(ans[i + 1], mk[i]);
    for (int i = 1; i <= n; ++i)
        write(abs(ans[i] - 1000000000)), pe;
    return 1;
}
signed main()
{
    freopen("min.in", "r", stdin);
    freopen("min.out", "w", stdout);
    n = read(), st1.init(), st2.init();
    for (int i = 1; i <= n; ++i)
        a[i] = st1.ask(i, i), b[i] = st2.ask(i, i);
    if (brute_force() || check_A() || check_B())
        return 0;
    return 0;
}
